{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ab43768c-5f6c-4575-831f-d2c764252293",
   "metadata": {},
   "source": [
    "Mistral - Langchain Ollama"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e31fa32e-2dbf-480d-884f-54e2e58fdbc8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name: langchain\n",
      "Version: 0.3.7\n",
      "Summary: Building applications with LLMs through composability\n",
      "Home-page: https://github.com/langchain-ai/langchain\n",
      "Author: \n",
      "Author-email: \n",
      "License: MIT\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: aiohttp, langchain-core, langchain-text-splitters, langsmith, numpy, pydantic, PyYAML, requests, SQLAlchemy, tenacity\n",
      "Required-by: langchain-community\n",
      "---\n",
      "Name: langchain-core\n",
      "Version: 0.3.19\n",
      "Summary: Building applications with LLMs through composability\n",
      "Home-page: https://github.com/langchain-ai/langchain\n",
      "Author: \n",
      "Author-email: \n",
      "License: MIT\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: jsonpatch, langsmith, packaging, pydantic, PyYAML, tenacity, typing-extensions\n",
      "Required-by: langchain, langchain-community, langchain-mistralai, langchain-ollama, langchain-text-splitters\n",
      "---\n",
      "Name: langchain-community\n",
      "Version: 0.3.7\n",
      "Summary: Community contributed LangChain integrations.\n",
      "Home-page: https://github.com/langchain-ai/langchain\n",
      "Author: \n",
      "Author-email: \n",
      "License: MIT\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: aiohttp, dataclasses-json, httpx-sse, langchain, langchain-core, langsmith, numpy, pydantic-settings, PyYAML, requests, SQLAlchemy, tenacity\n",
      "Required-by: \n",
      "---\n",
      "Name: langchain-ollama\n",
      "Version: 0.2.0\n",
      "Summary: An integration package connecting Ollama and LangChain\n",
      "Home-page: https://github.com/langchain-ai/langchain\n",
      "Author: \n",
      "Author-email: \n",
      "License: MIT\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: langchain-core, ollama\n",
      "Required-by: \n",
      "---\n",
      "Name: langchain-mistralai\n",
      "Version: 0.2.1\n",
      "Summary: An integration package connecting Mistral and LangChain\n",
      "Home-page: https://github.com/langchain-ai/langchain\n",
      "Author: \n",
      "Author-email: \n",
      "License: MIT\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: httpx, httpx-sse, langchain-core, pydantic, tokenizers\n",
      "Required-by: \n",
      "---\n",
      "Name: mistralai\n",
      "Version: 1.2.2\n",
      "Summary: Python Client SDK for the Mistral AI API.\n",
      "Home-page: https://github.com/mistralai/client-python.git\n",
      "Author: Mistral\n",
      "Author-email: \n",
      "License: \n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: eval-type-backport, httpx, jsonpath-python, pydantic, python-dateutil, typing-inspect\n",
      "Required-by: \n",
      "---\n",
      "Name: pydantic\n",
      "Version: 2.9.2\n",
      "Summary: Data validation using Python type hints\n",
      "Home-page: \n",
      "Author: \n",
      "Author-email: Samuel Colvin <s@muelcolvin.com>, Eric Jolibois <em.jolibois@gmail.com>, Hasan Ramezani <hasan.r67@gmail.com>, Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, Terrence Dorsey <terry@pydantic.dev>, David Montague <david@pydantic.dev>, Serge Matveenko <lig@countzero.co>, Marcelo Trylesinski <marcelotryle@gmail.com>, Sydney Runkle <sydneymarierunkle@gmail.com>, David Hewitt <mail@davidhewitt.io>, Alex Hall <alex.mojaki@gmail.com>\n",
      "License: \n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: annotated-types, pydantic-core, typing-extensions\n",
      "Required-by: langchain, langchain-core, langchain-mistralai, langsmith, mistralai, pydantic-settings\n"
     ]
    }
   ],
   "source": [
    "# show versions of dependent packages\n",
    "!pip show langchain langchain-core langchain-community langchain-ollama langchain-mistralai mistralai pydantic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ec70e220-f276-4981-b5bc-bb00007dd748",
   "metadata": {},
   "outputs": [],
   "source": [
    "ollama_url = \"http://ollama:11434\"\n",
    "# ollama_url = \"http://localhost:11434\"\n",
    "\n",
    "model_name = \"mistral:v0.3\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9730e237-fe97-4014-86f0-2031e4c50f7c",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_ollama import OllamaLLM\n",
    "\n",
    "llm = OllamaLLM(base_url=ollama_url,model=model_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "80345aa8-f679-48cf-80fb-438cdb6e7f94",
   "metadata": {},
   "outputs": [],
   "source": [
    "#from langchain.embeddings.ollama import OllamaEmbeddings\n",
    "from langchain_ollama import OllamaEmbeddings\n",
    "embeddings = OllamaEmbeddings(base_url=ollama_url, model=model_name)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d597fa2b-21c6-4127-8af2-fb7a126bbd25",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_core.output_parsers import StrOutputParser\n",
    "\n",
    "output_parser = StrOutputParser()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8bf30b7e-f7f9-4bf8-b02c-a570e5e5a5d6",
   "metadata": {},
   "source": [
    "\n",
    "# Sample to directly ask question to LLM\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f9b38fcd-8a9c-487c-aee1-5dae29d08841",
   "metadata": {},
   "outputs": [],
   "source": [
    "chain = llm | output_parser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ab8d7b0f-8894-4913-8e4d-0cad52f07004",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' Structurizr is a software modeling tool that helps developers and architects visualize, document, and communicate software architecture. It provides an intuitive web-based interface for creating diagrams such as context, package, component, database, sequence, and statechart diagrams. The main purpose of Structurizr is to aid in the design, communication, and evolution of software systems by creating clear, concise models. These models can then be exported into a variety of formats including markdown, HTML, PDF, and PowerPoint.'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"what is structurizr\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2bf4d410-7ecd-424f-bc59-19f546d48bc0",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "# Sample to use chat prompt templates\n",
    "\n",
    "With a better context provided to LLM.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c44c597e-48ac-40fb-b3f5-a387f05182d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "prompt = ChatPromptTemplate.from_messages([\n",
    "    (\"system\", \"You are a world class software architecture designer with knowledage of structurizr\"),\n",
    "    (\"user\", \"{input}\")\n",
    "])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "10154e23-c62f-400f-aa4a-6aee0b33c064",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_core.runnables import RunnableParallel, RunnablePassthrough\n",
    "\n",
    "retrieval = RunnableParallel(\n",
    "    {\"input\": RunnablePassthrough()}\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ad7b6b6b-8174-4cc3-8c33-7e4a358b6f05",
   "metadata": {},
   "outputs": [],
   "source": [
    "chain = retrieval | prompt | llm | output_parser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9ab35ccb-f927-4960-addd-f2c640805707",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' Structurizr is a lightweight, web-based software design tool that helps you visualize and document the architecture of your software system. It provides a simple way to create a visual representation of your application, including its components, their responsibilities, interactions, and dependencies. This helps in communicating and understanding the overall structure of the system, making it easier for developers and stakeholders to collaborate effectively during design and development phases. Additionally, Structurizr supports creation of architectural documentation in various formats like markdown, HTML, or PDF, which can be easily shared with team members or clients.'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"what is structurizr?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c536e351-994a-4831-84e1-83e611ac1c39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' Sure, here\\'s an example of a simple Structurizz DSL (Domain-Specific Language) for describing a multi-module software system. This example consists of three modules: API Gateway, User Service, and Item Service.\\n\\n```markdown\\n# System\\ntitle My Software System\\nsubTitle A sample software system consisting of an API gateway, user service, and item service\\n\\nmodules:\\n  - name: API Gateway\\n    icon: https://example.com/api-gateway.png\\n    color: #ff9900\\n    size: medium\\n\\n    components:\\n      - name: Auth API\\n        icon: https://example.com/auth-api.png\\n      - name: Main API\\n        icon: https://example.com/main-api.png\\n\\n  - name: User Service\\n    icon: https://example.com/user-service.png\\n    color: #6495ed\\n    size: large\\n\\n    components:\\n      - name: User Management\\n        icon: https://example.com/user-management.png\\n      - name: Registration API\\n        icon: https://example.com/registration-api.png\\n      - name: Authentication API\\n        icon: https://example.com/authentication-api.png\\n\\n  - name: Item Service\\n    icon: https://example.com/item-service.png\\n    color: #008000\\n    size: large\\n\\n    components:\\n      - name: Inventory Management\\n        icon: https://example.com/inventory-management.png\\n      - name: Item API\\n        icon: https://example.com/item-api.png\\n```\\n\\nIn this example, we have defined a system called \"My Software System\" with three modules: API Gateway, User Service, and Item Service. Each module has its own color, size, icon, and components (sub-modules). The components of each module are represented by their names, icons, and links to images. This DSL can be used to generate architecture diagrams, documentation, and code artifacts.'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"please provide example of structurizr dsl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "51464ac6-3318-4d8e-bf64-2874f8febdb9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\" I do not have real-time access to the internal systems or databases of specific companies, so I cannot definitively say whether company XYZ uses Structurizr DSL (Domain Specific Language). However, Structurizzr is a popular tool for modeling software architecture. If company XYZ values clear communication and well-organized software architecture, it's possible that they might use Structurizr or similar tools. To find out for certain, you should reach out to the appropriate contacts within the company.\""
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"Does company XYZ use structurizr dsl\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62a36647-c343-413f-9e77-4767bad54d39",
   "metadata": {},
   "source": [
    "\n",
    "# RAG Search Example\n",
    "\n",
    "https://python.langchain.com/docs/expression_language/get_started#rag-search-example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4721b06f-3770-4f92-bca7-8db6df58a962",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple/\n",
      "Collecting docarray\n",
      "  Downloading https://mirrors.ustc.edu.cn/pypi/packages/27/bf/90439e206a5d2df089e3467a703dfa0349f17d73f003ec51367db23bf8de/docarray-0.40.0-py3-none-any.whl (270 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m270.2/270.2 kB\u001b[0m \u001b[31m11.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: numpy>=1.17.3 in /opt/conda/lib/python3.11/site-packages (from docarray) (1.24.4)\n",
      "Requirement already satisfied: orjson>=3.8.2 in /opt/conda/lib/python3.11/site-packages (from docarray) (3.10.11)\n",
      "Requirement already satisfied: pydantic>=1.10.8 in /opt/conda/lib/python3.11/site-packages (from docarray) (2.9.2)\n",
      "Collecting rich>=13.1.0 (from docarray)\n",
      "  Downloading https://mirrors.ustc.edu.cn/pypi/packages/19/71/39c7c0d87f8d4e6c020a393182060eaefeeae6c01dab6a84ec346f2567df/rich-13.9.4-py3-none-any.whl (242 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m242.4/242.4 kB\u001b[0m \u001b[31m10.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting types-requests>=2.28.11.6 (from docarray)\n",
      "  Downloading https://mirrors.ustc.edu.cn/pypi/packages/d7/01/485b3026ff90e5190b5e24f1711522e06c79f4a56c8f4b95848ac072e20f/types_requests-2.32.0.20241016-py3-none-any.whl (15 kB)\n",
      "Requirement already satisfied: typing-inspect>=0.8.0 in /opt/conda/lib/python3.11/site-packages (from docarray) (0.9.0)\n",
      "Requirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.11/site-packages (from pydantic>=1.10.8->docarray) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.11/site-packages (from pydantic>=1.10.8->docarray) (2.23.4)\n",
      "Requirement already satisfied: typing-extensions>=4.6.1 in /opt/conda/lib/python3.11/site-packages (from pydantic>=1.10.8->docarray) (4.8.0)\n",
      "Collecting markdown-it-py>=2.2.0 (from rich>=13.1.0->docarray)\n",
      "  Downloading https://mirrors.ustc.edu.cn/pypi/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl (87 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m87.5/87.5 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: pygments<3.0.0,>=2.13.0 in /opt/conda/lib/python3.11/site-packages (from rich>=13.1.0->docarray) (2.16.1)\n",
      "Requirement already satisfied: urllib3>=2 in /opt/conda/lib/python3.11/site-packages (from types-requests>=2.28.11.6->docarray) (2.0.7)\n",
      "Requirement already satisfied: mypy-extensions>=0.3.0 in /opt/conda/lib/python3.11/site-packages (from typing-inspect>=0.8.0->docarray) (1.0.0)\n",
      "Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich>=13.1.0->docarray)\n",
      "  Downloading https://mirrors.ustc.edu.cn/pypi/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl (10.0 kB)\n",
      "Installing collected packages: types-requests, mdurl, markdown-it-py, rich, docarray\n",
      "Successfully installed docarray-0.40.0 markdown-it-py-3.0.0 mdurl-0.1.2 rich-13.9.4 types-requests-2.32.0.20241016\n"
     ]
    }
   ],
   "source": [
    "!pip install docarray"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2ef8f446-fbe6-4163-9cbd-fa70b6775b9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.11/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic.error_wrappers:ValidationError` has been moved to `pydantic:ValidationError`.\n",
      "  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')\n"
     ]
    }
   ],
   "source": [
    "from langchain_community.vectorstores import DocArrayInMemorySearch\n",
    "\n",
    "# https://docs.structurizr.com/\n",
    "vectorstore = DocArrayInMemorySearch.from_texts(\n",
    "    [\"\"\"\n",
    "    Structurizr builds upon \"diagrams as code\", allowing you to create multiple software architecture diagrams from a single model. \n",
    "    There are a number of tools for creating Structurizr compatible workspaces, with the Structurizr DSL being the recommended option for most teams.\n",
    "    \"\"\", \"\"\"\n",
    "    Structurizr builds upon \"diagrams as code\", allowing you to create multiple software architecture diagrams, in a variety of rendering tools, from a single model.\n",
    "    \"\"\",\n",
    "    \"Structurizr is a modelling tool, allowing you to create multiple diagrams from a single model.\",\n",
    "    \"\"\"\n",
    "    As an example, the following Structurizr DSL can be used to create a software architecture model and an associated view that describes a frontline staff using the \"MyWorkspace\" software system.\n",
    "    ---\n",
    "    workspace {\n",
    "\n",
    "        model {\n",
    "            user = person \"frontline staff\"\n",
    "            softwareSystem = softwareSystem \"MyWorkspace\"\n",
    "    \n",
    "            user -> softwareSystem \"Uses\"\n",
    "        }\n",
    "    \n",
    "        views {\n",
    "            systemContext softwareSystem {\n",
    "                include *\n",
    "                autolayout lr\n",
    "            }\n",
    "        }\n",
    "        \n",
    "    }\n",
    "    ---\n",
    "    \"\"\",\n",
    "    \"Some famous companies such as ABC and XYZ are using Structurizr DSL for software architecture modeling and documentation.\",],\n",
    "    embedding=embeddings,\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "4e3ecf98-abe2-427a-817e-7659100cb5aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "retriever = vectorstore.as_retriever()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6c3124c5-14c7-4432-a0b8-8406bc44bac9",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_core.runnables import RunnableParallel, RunnablePassthrough\n",
    "\n",
    "retrieval = RunnableParallel(\n",
    "    {\"context\": retriever, \"input\": RunnablePassthrough()}\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1f888ce1-8976-4c0c-80ce-2f7076ebd7f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "\n",
    "prompt = ChatPromptTemplate.from_messages([\n",
    "    (\"system\", \"\"\"You are a world class software architecture designer with knowledage of structurizr in the following context:\n",
    "    {context}\n",
    "\n",
    "    Please answer the question in the above context only, please do not make up anything if you do not know the answer.\n",
    "    \"\"\"),\n",
    "    (\"user\", \"{input}\")\n",
    "])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "1619ca62-9f50-4468-8ab5-8c40f0984076",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "chain = retrieval | prompt | llm | output_parser\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "728e10f3-0c16-4e3b-8538-4026eef5e942",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' Structurizr is a software architecture modeling and documentation tool that allows for creating multiple diagrams from a single model using the Structurizr Domain-Specific Language (DSL). It follows the principle of \"diagrams as code,\" meaning that software architecture diagrams can be generated in various rendering tools from a single source. The recommended option for most teams to create Structurizr compatible workspaces is by using the Structurizr DSL.'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"what is structurizr?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "8723909b-c331-4b6f-b348-b470c421b193",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' In the given context, an example of Structurizr DSL is provided:\\n\\n```markdown\\nworkspace {\\n  model {\\n    user = person \"frontline staff\"\\n    softwareSystem = softwareSystem \"MyWorkspace\"\\n    user -> softwareSystem \"Uses\"\\n  }\\n\\n  views {\\n    systemContext softwareSystem {\\n      include *\\n      autolayout lr\\n    }\\n  }\\n}\\n```\\n\\nThis example creates a software architecture model with two elements: a `user` (a person, specifically frontline staff) and a `softwareSystem` named \"MyWorkspace\". The relationship between them is that the user uses the MyWorkspace software system. Finally, it specifies a view for the system context of the software system, including all elements and automatically laying out the elements from left to right.'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"please provide example of structurizr dsl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "6074f2a1-637e-4c66-a4d6-be968f3a0f01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' According to the provided information, it is stated that some famous companies such as ABC and XYZ are using Structurizr DSL for software architecture modeling and documentation. Therefore, it can be inferred that company XYZ uses Structurizr DSL. However, it is important to note that this is an inference based on the given context, and further confirmation should be obtained directly from the company or official documents if necessary.'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"Does company XYZ use structurizr dsl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "dae9d771-4c58-4427-a4aa-94446ade35a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\" The document mentions that famous companies such as ABC and XYZ are using Structurizr DSL for software architecture modeling and documentation. However, I don't have specific names or details about these companies within the given context. It would be best to look up more information about these companies to confirm their use of Structurizr DSL.\""
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"what companies are using structurizr dsl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d7dfb6b3-faa4-48e2-9efe-2c88dba6b479",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' Here is an example of a Structurizr DSL related to the software system \"MyWorkspace\". This DSL creates a model and view that describes frontline staff using the \"MyWorkspace\" software system:\\n\\n```\\nworkspace {\\n    model {\\n        user = person \"frontline staff\"\\n        softwareSystem = softwareSystem \"MyWorkspace\"\\n        user -> softwareSystem \"Uses\"\\n    }\\n\\n    views {\\n        systemContext softwareSystem {\\n            include *\\n            autolayout lr\\n        }\\n    }\\n}\\n```\\n\\nThis DSL defines the workspace, its model with the user and MyWorkspace software systems, the relationship between the user and the software system (uses), and sets up a view for the system context. The `*` includes all elements in the diagram, and `autolayout lr` arranges the elements horizontally from left to right.\\n\\nMoreover, Structurizr enables you to create multiple software architecture diagrams in various rendering tools from this single model. Many famous companies like ABC and XYZ are using Structurizr DSL for software architecture modeling and documentation.'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke(\"\"\"\n",
    "please provide example of structurizr dsl related to software system \"MyWorkspace\"\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "6942744e-2657-4910-abe0-3d0ae2ec4f87",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name: docarray\n",
      "Version: 0.40.0\n",
      "Summary: The data structure for multimodal data\n",
      "Home-page: https://docs.docarray.org/\n",
      "Author: DocArray\n",
      "Author-email: \n",
      "License: Apache 2.0\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: numpy, orjson, pydantic, rich, types-requests, typing-inspect\n",
      "Required-by: \n"
     ]
    }
   ],
   "source": [
    "!pip show docarray"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4c2f08cb-5dd1-4751-b377-a0b882755f23",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
